<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>时间</title>
</head>
<body>
    <script>
        //获取时间
        //格林威治时间  1970 00:00:00.
            var date = new Date();
            console.log(date.toLocaleString())
            var month = date.getMonth()+1;//月份
            //var year = date.getYear();
            var weekDay = date.getDay();//返回一周的第几天
            var day = date.getDate();//返回一月的第几天
             var year = date.getFullYear();//完整的年份
            //console.log(year+"年"+month+"月"+ day+"日   星期"+weekDay)
            //console.log(typeof  day); //number
            var str = "";
       switch (weekDay){
           case 1:
               str = "星期1";
               break;
           case 2:
               str = "星期2";
               break;
           case 3:
               str = "星期3";
               break;
           case 4:
               str = "星期4";
               break;
           case 5:
               str = "星期5";
               break;
           case 6:
               str = "星期6";
               break;
           case 7:
               str = "星期天";
               break;
           default:
               console.log("日期不存在!")
               break;
        }
        document.write("<h3 style='color:red;'>"+year+"年"+month+"月"+day+"日  星期"+weekDay+"</h3>");
    </script>
</body>
</html>